﻿//======================================================
//==     (c)2008 aspxcms inc by NeTCMS v1.0              ==
//==          Forum:bbs.aspxcms.com                   ==
//==         Website:www.aspxcms.com                  ==
//======================================================
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text.RegularExpressions;

public partial class manage_collect_Collect_News : NetCMS.Web.UI.NPage //.ManagePage
{
    public manage_collect_Collect_News()
    {
        //Authority_Code = "S012";
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.Form["Option"] != null && !Request.Form["Option"].Trim().Equals("")
            && Request.Form["NewsID"] != null && !Request.Form["NewsID"].Trim().Equals(""))
        {
            try
            {
                NetCMS.Content.Collect.Collect cl = new NetCMS.Content.Collect.Collect();
                string id = Request.Form["NewsID"];
                if (Request.Form["Option"].Equals("DeleteNews"))
                {
                    cl.NewsDelete(id);
                    Response.Write("1%成功删除指定新闻!");
                }
            }
            catch (Exception ex)
            {
                Response.Write("0%" + ex.Message);
            }
            Response.End();
            return;
        }

        this.PageNavigator1.OnPageChange += new PageChangeHandler(PageNavigator1_OnPageChange);
        if (!Page.IsPostBack)
        {
            ListDataBind(1);
        }
    }
    protected void PageNavigator1_OnPageChange(object sender, int PageIndex)
    {
        ListDataBind(PageIndex);
    }
    private void ListDataBind(int PageIndex)
    {
        int nRCount, nPCount;
        NetCMS.Content.Collect.Collect cl = new NetCMS.Content.Collect.Collect();
        //this.RptNews.DataSource = cl.GetNewsPage(PageIndex, PAGESIZE, out nRCount, out nPCount);
        this.RptNews.DataSource = cl.GetNewsPage(PageIndex, 20, out nRCount, out nPCount);
        this.RptNews.DataBind();
        this.PageNavigator1.PageCount = nPCount;
        this.PageNavigator1.RecordCount = nRCount;
        this.PageNavigator1.PageIndex = PageIndex;
    }
    protected void RptNews_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            Label lbl = (Label)e.Item.FindControl("LblState");
            if (lbl != null)
            {
                try
                {
                    bool flag = Convert.ToBoolean(lbl.Text);
                    if (flag)
                    {
                        lbl.Text = "已入库";
                        lbl.ForeColor = System.Drawing.Color.Red;
                    }
                    else
                    {
                        lbl.Text = "未入库";
                    }
                }
                catch { }
            }
        }
    }
}
